using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Diagnostics;

namespace GoodStuff
{
    public abstract class GoodControlBase : IGoodControl
    {
        protected Control _control;
        public Control Control
        {
            get { return _control; }
        }

        protected Dictionary<string, object> _parameterList;
        public Dictionary<string, object> ParameterList
        {
            get { return _parameterList; }
            set { _parameterList = value; }
        }

        public virtual void Initialize()
        {
        }

        abstract protected void OnVariableChanged(object sender, EventArgs args);

        protected string ParameterText(string key)
        {
            if(_parameterList.ContainsKey(key))
                return (string)_parameterList[key];
            else
                return null;
        }

        protected IGoodVariable ParameterVariable(string key)
        {
            if (_parameterList.ContainsKey(key))
            {
                IGoodVariable gv = _parameterList[key] as IGoodVariable;
                string s = _parameterList[key] as string;
                if (s != null)
                    return (IGoodVariable) StateStore.Store[s];
                else
                    return gv;
            }
            else
                return null;
       }

       protected IGoodConvertibleVariable ParameterNumericVariable(string key)
       {
           if (_parameterList.ContainsKey(key))
               return (IGoodConvertibleVariable)_parameterList[key];
           else
               return null;
       }

   }


}
